﻿using AnQinFrameWorkAPI.Entity.SystemCore.DTO.RoleField;
using AnQinFrameWorkAPI.Entity.SystemCore.View.RoleField;
using AnQinFrameWorkAPI.Service.SystemCore;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.SystemCore;

/// <summary>
///     角色字段API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "SystemCore")]
public class RoleFieldController : ControllerBase
{
    //业务接口
    private readonly RoleFieldService _roleFieldService;

    //构造注入
    public RoleFieldController(RoleFieldService roleFieldService)
    {
        _roleFieldService = roleFieldService;
    }

    /// <summary>
    ///     获取角色字段列表
    /// </summary>
    [ProducesResponseType(typeof(RoleFieldView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetRoleMenuList([FromQuery] RoleFieldSearchDTO roleFieldSearchDto)
    {
        var response = await _roleFieldService.GetRoleFieldList(roleFieldSearchDto);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     启用角色字段
    /// </summary>
    [HttpPost("EnableMulti")]
    public async Task<IActionResult> EnableRoleMenu([FromBody] RoleFieldUpdateDTO roleFieldUpdateDto)
    {
        var response = await _roleFieldService.EnableMultiRoleField(roleFieldUpdateDto);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     禁用角色字段
    /// </summary>
    [HttpPost("DisableMulti")]
    public async Task<IActionResult> DisableRoleMenu([FromBody] RoleFieldUpdateDTO roleFieldUpdateDto)
    {
        var response = await _roleFieldService.DisableMultiRoleField(roleFieldUpdateDto);
        return StatusCode(response.Status, response);
    }
}